<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.dic.service.WorddictionaryService"%>
<%@ page import="com.dic.dao.*"%>
<%@ page import="com.dic.dao.model.*"%>
<%@ page import="com.google.gson.Gson" %>
<%@ page import="java.text.DateFormat"%>
<%@ page import="java.text.SimpleDateFormat"%>

<%
   request.setCharacterEncoding("UTF-8");
   response.setCharacterEncoding("UTF-8");
   Date date=new Date();
   DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
   
   String wordobj=request.getParameter("wordobj");
   
   Gson gson = new Gson();
   Worddictionary worddic=gson.fromJson(wordobj, Worddictionary.class); 
   //如果编录日期不为空，则不变，若为空，则在此处添加日期
   //System.out.println("bb:"+worddic.getDate());
   if(worddic.getDate()=="" || worddic.getDate()==null ||worddic.getDate().equals("")){
       //System.out.println("cc");
       worddic.setDate(df.format(date));
   }
   worddic.setRenewdate(df.format(date));
   
   //System.out.println(worddic.getSynonym1()+";"+worddic.getSynonym2()+";"+worddic.getAntonym1());
   
   WorddictionaryService ser = new WorddictionaryService();
   int updateflag=ser.updateWord(worddic);
   
   if(updateflag==1){
     out.print("{'result':'success'}");
   }else{
     out.print("{'result':'fail'}");
   }
   
   
%>